﻿package tk.mystudio.permission.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;

import tk.mystudio.dao.impl.BaseDaoImpl;
import tk.mystudio.permission.bean.AccountRole;
import tk.mystudio.permission.dao.AccountRoleDao;

public class AccountRoleDaoImpl extends BaseDaoImpl<AccountRole> implements
		AccountRoleDao {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Override
	public void revokeAccountRoleByAccountId(Integer accountId) {
		Assert.notNull(accountId);
		AccountRole accountRole = new AccountRole();
		accountRole.setAccountId(accountId);
		List<AccountRole> list = getList(accountRole);
		for(AccountRole obj : list) {
			if (obj != null) {
				baseDaoSupport.getJpaTemplate().remove(obj);
			}
		}
	}

	@Override
	public void revokeAccountRoleByRoleId(Integer roleId) {
		Assert.notNull(roleId);
		AccountRole accountRole = new AccountRole();
		accountRole.setRoleId(roleId);
		List<AccountRole> list = getList(accountRole);
		for(AccountRole obj : list) {
			if (obj != null) {
				baseDaoSupport.getJpaTemplate().remove(obj);
			}
		}
	}
	
}
